<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<title>登陆</title>
<link type="text/css" rel="stylesheet" href="../css/base.css" />
<link type="text/css" rel="stylesheet" href="../css/newreg.css" />
<!--script type="text/javascript" src="http://www.gouwutu.com/n2/v2/css/nav/jquery.js"></script-->
<style type="text/css">
#userCuo, #passCuo { color:red; line-height:25px;}
</style>
<script type="text/javascript" src="../js/jquery-1.4.4.js"></script>
<script type="text/javascript">
function check_user_logon(){
	var username = $("#username").val();
	var password = $("#password").val();
	if(username.length == 0){
		$("#userCuo").html("<span>请输入你的注册邮箱/昵称</span>");
		$('#userCuo').show();
        return false;
	}
	if (username == '注册时使用的邮箱/昵称') {
    	$('#userCuo').html("<span>请输入邮箱和密码</span>");
    	$('#userCuo').show();
     	return false;
     }
	 if (password.length == 0) {
		$('#passCuo').html("<span>请输入密码</span>");
		$('#passCuo').show();
		return false;
     }
	 
	return true;
}
</script>
</head>

<?PHP
session_start();
include("../config/connect.php");
include("../public/common.php");

$ref = CheckUrlParamNoDie("ref");
if ($ref=="")	$ref = "http://www.tusijie.com/user";
$email = trim(GetPostParamStr("username"));
$psw = trim(GetPostParamStr("password"));

if (HasLogin())
{
	$url = "Location:".$ref;
	header($url);
	exit;
}

if( $email != "" && $psw != "" )
{
	$sql = "select * from tsj_user where email='$email' limit 1";
	$result = mysql_query( $sql );
	if (mysql_num_rows($result) > 0)
	{
		//
		$row = mysql_fetch_assoc( $result );
		if ($row["password"] != "")
		{
			if (md5($psw) == $row["password"])
			{
				$_SESSION["isoauth"] = 0;
				$_SESSION["email"] = $email;
				$_SESSION["userid"] = $row["id"];
				$_SESSION["nickname"] = $row["nick_name"];
				$_SESSION["right"] = $row["right"];
			
				$url = "Location:".$ref;
				header($url);
			}
			else
			{
				echo "<script>alert('密码错误！');</script>";
			}
		}
		else
		{
			echo "<script>alert('您没有升级账号，不能分享！');</script>";
		}
	}
	else
	{
		echo "<script>alert('不存在的账号！');</script>";
	}
}
?>

<body>
<div id="wrapper">
<!---head kaishi--->
     <?php
		 include("../headtop.php"); 
	?>
<!-----head 结束----->
<div id="frame_logo_wrapper">
	<div id="frame_page_wrapper_content">
			<!-- google_ad_section_start -->
		<div class="register-page-wrapper" id="newRegForm">
			<div class="left newRegFromMain user-left">	
				<div>
					<h1>登录 兔丝街</h1>
					<div class="reg-desc">和兔丝们一起淘宝贝，逛精品！还能享受兔丝特权，购物更省钱！</div>
				</div>
				<div class="dash-line"></div>
                <!----logon _start---->
				<form id="loginForm" onsubmit="return check_user_logon();" action="" method="post">
                    <div class="logon_form_input_email ">
                        <div class="titleBox left">账  号：</div>
                        <div class="titleBox left" style="width:180px;">
                            <input type="text" onfocus="if(this.value=='注册时使用的邮箱') this.value='';" value="<?PHP if ($email=="") echo "注册时使用的邮箱"; else echo $email; ?>" class="logonInput" id="username" name="username">
                        </div>
                        <div class="left" id="userCuo"></div>
                        <div class="clear-fix"></div>
                    </div>
                    <div class="logon_form_input_pass">
                        <div class="">
                            <div class="left titleBox">密  码：</div>
                            <div class="left" style="width:180px;"><input type="password" value="" class=" logonInput" id="password" name="password"></div>
                            <div class="left" id="passCuo"></div>
                        </div>
                    </div>
                    <div class="clear-fix"></div>
                    <input type="hidden" name="action" value="submitted">
                    <input type="submit" name="submit" class="button button-100 submitLogon" value="登   录">
				</form>
			<!----logon _end---->
			</div>

            <div class="left newRegFromRight">
                <div class="reg-desc">还没有兔丝街账号？<a href="register.php">立即注册</a></div>
                <div>
                    你也可以用站外账号登录:<br><br>
                    <a href="../public/weibosdk/oauth"><img src="http://www.tusijie.com/images/linksina.png"></a><br><br>
                    <a href="../public/qqsdk/oauth/redirect_to_login.php"><img src="http://www.tusijie.com/images/connect_Q.png"></a><br><br>
                </div>
            	
            </div>
            <div style="clear:both"></div>
        </div>
        <!-- google_ad_section_end -->
        <div class="clear-fix"></div>
        <!-- google_ad_section_start(weight=ignore) -->	
	</div>
	<div style="clear:both"></div>
<!-- google_ad_section_end -->
</div>
</div>
<!---网尾 kaishi--->
 <?php
     include("../networkend.php"); 
?>
<!------------>
</body>
</html>

<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F22b7662ec7d02c816ddfd8f6df6e5cea' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-20984072-3']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>